#ifndef X33_H
#define X33_H

#include "common.h"

template <AllegroVersion version>
struct x33
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;
    
    uint32_t k;
    uint32_t un1;
    
    uint32_t ptr1;
    
    // Some bit field?
    uint32_t un2;
    
    uint32_t ptr2;
    
    int32_t coords[2];
    
    // Points to instance of `x05` or `0x09` (or null).
    uint32_t ptr3;
    
    uint32_t ptr4;
    
    // Null or pointer to (always empty?) string
    uint32_t ptr5;
    
    uint32_t ptr6;
    
    // Occassionally non-zero integers? Maybe bit fields?
    uint32_t un3[2];
    
    int32_t bb_coords[4];
    
    uint32_t TAIL;
    operator x33<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus >= 202002L
template <AllegroVersion version> requires(version >= A_172)
struct x33<version>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;
    uint32_t un1;

    uint32_t ptr1;

    // Some bit field?
    uint32_t un2;
    uint32_t un4;

    uint32_t ptr2;

    uint32_t ptr7;

    int32_t coords[2];

    // Points to instance of `x05` or `0x09` (or null).
    uint32_t ptr3;

    uint32_t ptr4;

    // Null or pointer to (always empty?) string
    uint32_t ptr5;

    uint32_t ptr6;

    // Occassionally non-zero integers? Maybe bit fields?
    uint32_t un3[2];

    int32_t bb_coords[4];

    uint32_t TAIL;
    operator x33<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
#else
template <> struct x33<A_172>
{
    uint16_t t;
    uint8_t subtype;
    uint8_t layer;

    uint32_t k;
    uint32_t un1;

    uint32_t ptr1;

    // Some bit field?
    uint32_t un2;
    uint32_t un4;

    uint32_t ptr2;

    uint32_t ptr7;

    int32_t coords[2];

    // Points to instance of `x05` or `0x09` (or null).
    uint32_t ptr3;

    uint32_t ptr4;

    // Null or pointer to (always empty?) string
    uint32_t ptr5;

    uint32_t ptr6;

    // Occassionally non-zero integers? Maybe bit fields?
    uint32_t un3[2];

    int32_t bb_coords[4];

    uint32_t TAIL;
    operator x33<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};
template <> struct x33<A_174> : x33<A_172> {};
#endif

#endif // X33_H
